<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class Gem::RemoteFetcher - rubygems: Ruby Standard Library Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

        
<div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">
    <li><a class="include" href="UserInteraction.html">Gem::UserInteraction</a>
  </ul>
</div>

        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-fetcher">::fetcher</a>
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-cache_update_path">#cache_update_path</a>
    <li ><a href="#method-i-close_all">#close_all</a>
    <li ><a href="#method-i-download">#download</a>
    <li ><a href="#method-i-download_to_cache">#download_to_cache</a>
    <li ><a href="#method-i-fetch_file">#fetch_file</a>
    <li ><a href="#method-i-fetch_http">#fetch_http</a>
    <li ><a href="#method-i-fetch_https">#fetch_https</a>
    <li ><a href="#method-i-fetch_path">#fetch_path</a>
    <li ><a href="#method-i-fetch_s3">#fetch_s3</a>
    <li ><a href="#method-i-https-3F">#https?</a>
    <li ><a href="#method-i-pools_for">#pools_for</a>
    <li ><a href="#method-i-proxy_for">#proxy_for</a>
    <li ><a href="#method-i-request">#request</a>
    <li ><a href="#method-i-s3_uri_signer">#s3_uri_signer</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-Gem::RemoteFetcher">
    <h1 id="class-Gem::RemoteFetcher" class="class">
      class Gem::RemoteFetcher
    </h1>

    <section class="description">
    
<p><a href="RemoteFetcher.html"><code>RemoteFetcher</code></a> handles the details of fetching gems and gem information from a remote source.</p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">



        <section class="attribute-method-details" class="method-section">
        <header>
        <h3>Attributes</h3>
        </header>

          <div id="attribute-i-headers" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">headers</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              
              </div>
            </div>
            </section>


                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-fetcher" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">fetcher</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Cached <a href="RemoteFetcher.html"><code>RemoteFetcher</code></a> instance.</p>

                              <div class="method-source-code" id="fetcher-source">
            <pre><span class="ruby-comment"># File rubygems/remote_fetcher.rb, line 55</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">fetcher</span>
  <span class="ruby-ivar">@fetcher</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">new</span> <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">configuration</span>[<span class="ruby-value">:http_proxy</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">(proxy=nil, dns=nil, headers={})</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Initialize a remote fetcher using the source URI and possible proxy information.</p>

<p><code>proxy</code></p>
<ul><li>
<p>[String]: explicit specification of proxy; overrides any environment</p>

<pre class="ruby"><span class="ruby-identifier">variable</span> <span class="ruby-identifier">setting</span>
</pre>
</li><li>
<p>nil: respect environment variables (HTTP_PROXY, HTTP_PROXY_USER,</p>

<pre>HTTP_PROXY_PASS)</pre>
</li><li>
<p><code>:no_proxy</code>: ignore environment variables and _don’t_ use a proxy</p>
</li></ul>

<p><code>headers</code>: A set of additional HTTP headers to be sent to the server when</p>

<pre>fetching the gem.</pre>

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File rubygems/remote_fetcher.rb, line 75</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">proxy</span>=<span class="ruby-keyword">nil</span>, <span class="ruby-identifier">dns</span>=<span class="ruby-keyword">nil</span>, <span class="ruby-identifier">headers</span>={})
  <span class="ruby-identifier">require_relative</span> <span class="ruby-string">&quot;core_ext/tcpsocket_init&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">configuration</span>.<span class="ruby-identifier">ipv4_fallback_enabled</span>
  <span class="ruby-identifier">require</span> <span class="ruby-string">&quot;net/http&quot;</span>
  <span class="ruby-identifier">require</span> <span class="ruby-string">&quot;stringio&quot;</span>
  <span class="ruby-identifier">require</span> <span class="ruby-string">&quot;uri&quot;</span>

  <span class="ruby-constant">Socket</span>.<span class="ruby-identifier">do_not_reverse_lookup</span> = <span class="ruby-keyword">true</span>

  <span class="ruby-ivar">@proxy</span> = <span class="ruby-identifier">proxy</span>
  <span class="ruby-ivar">@pools</span> = {}
  <span class="ruby-ivar">@pool_lock</span> = <span class="ruby-constant">Thread</span><span class="ruby-operator">::</span><span class="ruby-constant">Mutex</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-ivar">@cert_files</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">get_cert_files</span>

  <span class="ruby-ivar">@headers</span> = <span class="ruby-identifier">headers</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-cache_update_path" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">cache_update_path</span><span
                                class="method-args">(uri, path = nil, update = true)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Downloads <code>uri</code> to <code>path</code> if necessary. If no path is given, it just passes the data.</p>

                              <div class="method-source-code" id="cache_update_path-source">
            <pre><span class="ruby-comment"># File rubygems/remote_fetcher.rb, line 287</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">cache_update_path</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">path</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">update</span> = <span class="ruby-keyword">true</span>)
  <span class="ruby-identifier">mtime</span> = <span class="ruby-keyword">begin</span>
            <span class="ruby-identifier">path</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-identifier">path</span>).<span class="ruby-identifier">mtime</span>
          <span class="ruby-keyword">rescue</span> <span class="ruby-constant">StandardError</span>
            <span class="ruby-keyword">nil</span>
          <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">data</span> = <span class="ruby-identifier">fetch_path</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">mtime</span>)

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-comment"># indicates the server returned 304 Not Modified</span>
    <span class="ruby-keyword">return</span> <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">read_binary</span>(<span class="ruby-identifier">path</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">update</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">path</span>
    <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">write_binary</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">data</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">data</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-close_all" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">close_all</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="close_all-source">
            <pre><span class="ruby-comment"># File rubygems/remote_fetcher.rb, line 327</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">close_all</span>
  <span class="ruby-ivar">@pools</span>.<span class="ruby-identifier">each_value</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:close_all</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-download" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">download</span><span
                                class="method-args">(spec, source_uri, install_dir = Gem.dir)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Moves the gem <code>spec</code> from <code>source_uri</code> to the cache dir unless it is already there.  If the source_uri is local the gem cache dir copy is always replaced.</p>

                              <div class="method-source-code" id="download-source">
            <pre><span class="ruby-comment"># File rubygems/remote_fetcher.rb, line 113</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">download</span>(<span class="ruby-identifier">spec</span>, <span class="ruby-identifier">source_uri</span>, <span class="ruby-identifier">install_dir</span> = <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">dir</span>)
  <span class="ruby-identifier">install_cache_dir</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span> <span class="ruby-identifier">install_dir</span>, <span class="ruby-string">&quot;cache&quot;</span>
  <span class="ruby-identifier">cache_dir</span> =
    <span class="ruby-keyword">if</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">pwd</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">install_dir</span> <span class="ruby-comment"># see fetch_command</span>
      <span class="ruby-identifier">install_dir</span>
    <span class="ruby-keyword">elsif</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">writable?</span>(<span class="ruby-identifier">install_cache_dir</span>) <span class="ruby-operator">||</span> (<span class="ruby-constant">File</span>.<span class="ruby-identifier">writable?</span>(<span class="ruby-identifier">install_dir</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">install_cache_dir</span>))
      <span class="ruby-identifier">install_cache_dir</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span> <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">user_dir</span>, <span class="ruby-string">&quot;cache&quot;</span>
    <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">gem_file_name</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span> <span class="ruby-identifier">spec</span>.<span class="ruby-identifier">cache_file</span>
  <span class="ruby-identifier">local_gem_path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span> <span class="ruby-identifier">cache_dir</span>, <span class="ruby-identifier">gem_file_name</span>

  <span class="ruby-identifier">require</span> <span class="ruby-string">&quot;fileutils&quot;</span>
  <span class="ruby-keyword">begin</span>
    <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span> <span class="ruby-identifier">cache_dir</span>
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">StandardError</span>
    <span class="ruby-keyword">nil</span>
  <span class="ruby-keyword">end</span> <span class="ruby-keyword">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span> <span class="ruby-identifier">cache_dir</span>

  <span class="ruby-identifier">source_uri</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Uri</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">source_uri</span>)

  <span class="ruby-identifier">scheme</span> = <span class="ruby-identifier">source_uri</span>.<span class="ruby-identifier">scheme</span>

  <span class="ruby-comment"># URI.parse gets confused by MS Windows paths with forward slashes.</span>
  <span class="ruby-identifier">scheme</span> = <span class="ruby-keyword">nil</span> <span class="ruby-keyword">if</span> <span class="ruby-regexp">/^[a-z]$/i</span>.<span class="ruby-identifier">match?</span>(<span class="ruby-identifier">scheme</span>)

  <span class="ruby-comment"># REFACTOR: split this up and dispatch on scheme (eg download_http)</span>
  <span class="ruby-comment"># REFACTOR: be sure to clean up fake fetcher when you do this... cleaner</span>
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">scheme</span>
  <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;http&quot;</span>, <span class="ruby-string">&quot;https&quot;</span>, <span class="ruby-string">&quot;s3&quot;</span> <span class="ruby-keyword">then</span>
    <span class="ruby-keyword">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span> <span class="ruby-identifier">local_gem_path</span>
      <span class="ruby-keyword">begin</span>
        <span class="ruby-identifier">verbose</span> <span class="ruby-node">&quot;Downloading gem #{gem_file_name}&quot;</span>

        <span class="ruby-identifier">remote_gem_path</span> = <span class="ruby-identifier">source_uri</span> <span class="ruby-operator">+</span> <span class="ruby-node">&quot;gems/#{gem_file_name}&quot;</span>

        <span class="ruby-identifier">cache_update_path</span> <span class="ruby-identifier">remote_gem_path</span>, <span class="ruby-identifier">local_gem_path</span>
      <span class="ruby-keyword">rescue</span> <span class="ruby-constant">FetchError</span>
        <span class="ruby-identifier">raise</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">spec</span>.<span class="ruby-identifier">original_platform</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">spec</span>.<span class="ruby-identifier">platform</span>

        <span class="ruby-identifier">alternate_name</span> = <span class="ruby-node">&quot;#{spec.original_name}.gem&quot;</span>

        <span class="ruby-identifier">verbose</span> <span class="ruby-node">&quot;Failed, downloading gem #{alternate_name}&quot;</span>

        <span class="ruby-identifier">remote_gem_path</span> = <span class="ruby-identifier">source_uri</span> <span class="ruby-operator">+</span> <span class="ruby-node">&quot;gems/#{alternate_name}&quot;</span>

        <span class="ruby-identifier">cache_update_path</span> <span class="ruby-identifier">remote_gem_path</span>, <span class="ruby-identifier">local_gem_path</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;file&quot;</span> <span class="ruby-keyword">then</span>
    <span class="ruby-keyword">begin</span>
      <span class="ruby-identifier">path</span> = <span class="ruby-identifier">source_uri</span>.<span class="ruby-identifier">path</span>
      <span class="ruby-identifier">path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">path</span>) <span class="ruby-keyword">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">extname</span>(<span class="ruby-identifier">path</span>) <span class="ruby-operator">==</span> <span class="ruby-string">&quot;.gem&quot;</span>

      <span class="ruby-identifier">remote_gem_path</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">correct_for_windows_path</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">path</span>, <span class="ruby-string">&quot;gems&quot;</span>, <span class="ruby-identifier">gem_file_name</span>))

      <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp</span>(<span class="ruby-identifier">remote_gem_path</span>, <span class="ruby-identifier">local_gem_path</span>)
    <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EACCES</span>
      <span class="ruby-identifier">local_gem_path</span> = <span class="ruby-identifier">source_uri</span>.<span class="ruby-identifier">to_s</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">verbose</span> <span class="ruby-node">&quot;Using local gem #{local_gem_path}&quot;</span>
  <span class="ruby-keyword">when</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">then</span> <span class="ruby-comment"># TODO: test for local overriding cache</span>
    <span class="ruby-identifier">source_path</span> = <span class="ruby-keyword">if</span> <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">win_platform?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">source_uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">&amp;&amp;</span>
                     <span class="ruby-operator">!</span><span class="ruby-identifier">source_uri</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&quot;:&quot;</span>)
      <span class="ruby-node">&quot;#{source_uri.scheme}:#{source_uri.path}&quot;</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">source_uri</span>.<span class="ruby-identifier">path</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">source_path</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">UriFormatter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">source_path</span>).<span class="ruby-identifier">unescape</span>

    <span class="ruby-keyword">begin</span>
      <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp</span> <span class="ruby-identifier">source_path</span>, <span class="ruby-identifier">local_gem_path</span> <span class="ruby-keyword">unless</span>
        <span class="ruby-constant">File</span>.<span class="ruby-identifier">identical?</span>(<span class="ruby-identifier">source_path</span>, <span class="ruby-identifier">local_gem_path</span>)
    <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EACCES</span>
      <span class="ruby-identifier">local_gem_path</span> = <span class="ruby-identifier">source_uri</span>.<span class="ruby-identifier">to_s</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">verbose</span> <span class="ruby-node">&quot;Using local gem #{local_gem_path}&quot;</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;unsupported URI scheme #{source_uri.scheme}&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">local_gem_path</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-download_to_cache" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">download_to_cache</span><span
                                class="method-args">(dependency)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Given a name and requirement, downloads this gem into cache and returns the filename. Returns nil if the gem cannot be located.</p>

                              <div class="method-source-code" id="download_to_cache-source">
            <pre><span class="ruby-comment"># File rubygems/remote_fetcher.rb, line 98</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">download_to_cache</span>(<span class="ruby-identifier">dependency</span>)
  <span class="ruby-identifier">found</span>, <span class="ruby-identifier">_</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">SpecFetcher</span>.<span class="ruby-identifier">fetcher</span>.<span class="ruby-identifier">spec_for_dependency</span> <span class="ruby-identifier">dependency</span>

  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">found</span>.<span class="ruby-identifier">empty?</span>

  <span class="ruby-identifier">spec</span>, <span class="ruby-identifier">source</span> = <span class="ruby-identifier">found</span>.<span class="ruby-identifier">max_by</span> {<span class="ruby-operator">|</span>(<span class="ruby-identifier">s</span>,<span class="ruby-identifier">_</span>)<span class="ruby-operator">|</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">version</span> }

  <span class="ruby-identifier">download</span> <span class="ruby-identifier">spec</span>, <span class="ruby-identifier">source</span>.<span class="ruby-identifier">uri</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-fetch_file" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">fetch_file</span><span
                                class="method-args">(uri, *_)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>File Fetcher. Dispatched by <code>fetch_path</code>. Use it instead.</p>

                              <div class="method-source-code" id="fetch_file-source">
            <pre><span class="ruby-comment"># File rubygems/remote_fetcher.rb, line 205</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">fetch_file</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">_</span>)
  <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">read_binary</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">correct_for_windows_path</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-fetch_http" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">fetch_http</span><span
                                class="method-args">(uri, last_modified = nil, head = false, depth = 0)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>HTTP Fetcher. Dispatched by <code>fetch_path</code>. Use it instead.</p>

                              <div class="method-source-code" id="fetch_http-source">
            <pre><span class="ruby-comment"># File rubygems/remote_fetcher.rb, line 212</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">fetch_http</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">last_modified</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">head</span> = <span class="ruby-keyword">false</span>, <span class="ruby-identifier">depth</span> = <span class="ruby-value">0</span>)
  <span class="ruby-identifier">fetch_type</span> = <span class="ruby-identifier">head</span> <span class="ruby-operator">?</span> <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Head</span> <span class="ruby-operator">:</span> <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Get</span>
  <span class="ruby-identifier">response</span>   = <span class="ruby-identifier">request</span> <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">fetch_type</span>, <span class="ruby-identifier">last_modified</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">req</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">req</span>.<span class="ruby-identifier">add_field</span>(<span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span>) }
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">case</span> <span class="ruby-identifier">response</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPOK</span>, <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPNotModified</span> <span class="ruby-keyword">then</span>
    <span class="ruby-identifier">response</span>.<span class="ruby-identifier">uri</span> = <span class="ruby-identifier">uri</span>
    <span class="ruby-identifier">head</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">response</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">response</span>.<span class="ruby-identifier">body</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPMovedPermanently</span>, <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPFound</span>, <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPSeeOther</span>,
       <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPTemporaryRedirect</span> <span class="ruby-keyword">then</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">FetchError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;too many redirects&quot;</span>, <span class="ruby-identifier">uri</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">depth</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">10</span>

    <span class="ruby-keyword">unless</span> <span class="ruby-identifier">location</span> = <span class="ruby-identifier">response</span>[<span class="ruby-string">&quot;Location&quot;</span>]
      <span class="ruby-identifier">raise</span> <span class="ruby-constant">FetchError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;redirecting but no redirect location was given&quot;</span>, <span class="ruby-identifier">uri</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">location</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Uri</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">location</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">https?</span>(<span class="ruby-identifier">uri</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">https?</span>(<span class="ruby-identifier">location</span>)
      <span class="ruby-identifier">raise</span> <span class="ruby-constant">FetchError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;redirecting to non-https resource: #{location}&quot;</span>, <span class="ruby-identifier">uri</span>)
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">fetch_http</span>(<span class="ruby-identifier">location</span>, <span class="ruby-identifier">last_modified</span>, <span class="ruby-identifier">head</span>, <span class="ruby-identifier">depth</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">FetchError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;bad response #{response.message} #{response.code}&quot;</span>, <span class="ruby-identifier">uri</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="RemoteFetcher.html#method-i-fetch_https">fetch_https</a>
                            </div>

                          </div>

                  <div id="method-i-fetch_https" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">fetch_https</span><span
                                class="method-args">(uri, last_modified = nil, head = false, depth = 0)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="RemoteFetcher.html#method-i-fetch_http">fetch_http</a>
                            </div>
                          </div>

                  <div id="method-i-fetch_path" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">fetch_path</span><span
                                class="method-args">(uri, mtime = nil, head = false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Downloads <code>uri</code> and returns it as a String.</p>

                              <div class="method-source-code" id="fetch_path-source">
            <pre><span class="ruby-comment"># File rubygems/remote_fetcher.rb, line 246</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">fetch_path</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">mtime</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">head</span> = <span class="ruby-keyword">false</span>)
  <span class="ruby-identifier">uri</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Uri</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">uri</span>

  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;uri scheme is invalid: #{uri.scheme.inspect}&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">data</span> = <span class="ruby-identifier">send</span> <span class="ruby-node">&quot;fetch_#{uri.scheme}&quot;</span>, <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">mtime</span>, <span class="ruby-identifier">head</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">data</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">head</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">end_with?</span>(<span class="ruby-string">&quot;.gz&quot;</span>)
    <span class="ruby-keyword">begin</span>
      <span class="ruby-identifier">data</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">gunzip</span> <span class="ruby-identifier">data</span>
    <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">GzipFile</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-constant">FetchError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;server did not return a valid file&quot;</span>, <span class="ruby-identifier">uri</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">data</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Timeout</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span>, <span class="ruby-constant">IOError</span>, <span class="ruby-constant">SocketError</span>, <span class="ruby-constant">SystemCallError</span>,
       <span class="ruby-operator">*</span>(<span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSLError</span> <span class="ruby-keyword">if</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">HAVE_OPENSSL</span>) <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">e</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">FetchError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;#{e.class}: #{e}&quot;</span>, <span class="ruby-identifier">uri</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-fetch_s3" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">fetch_s3</span><span
                                class="method-args">(uri, mtime = nil, head = false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="fetch_s3-source">
            <pre><span class="ruby-comment"># File rubygems/remote_fetcher.rb, line 269</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">fetch_s3</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">mtime</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">head</span> = <span class="ruby-keyword">false</span>)
  <span class="ruby-keyword">begin</span>
    <span class="ruby-identifier">public_uri</span> = <span class="ruby-identifier">s3_uri_signer</span>(<span class="ruby-identifier">uri</span>).<span class="ruby-identifier">sign</span>
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">S3URISigner</span><span class="ruby-operator">::</span><span class="ruby-constant">ConfigurationError</span>, <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">S3URISigner</span><span class="ruby-operator">::</span><span class="ruby-constant">InstanceProfileError</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">e</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">FetchError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>, <span class="ruby-node">&quot;s3://#{uri.host}&quot;</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">fetch_https</span> <span class="ruby-identifier">public_uri</span>, <span class="ruby-identifier">mtime</span>, <span class="ruby-identifier">head</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-https-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">https?</span><span
                                class="method-args">(uri)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="https-3F-source">
            <pre><span class="ruby-comment"># File rubygems/remote_fetcher.rb, line 323</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">https?</span>(<span class="ruby-identifier">uri</span>)
  <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span>.<span class="ruby-identifier">casecmp</span>(<span class="ruby-string">&quot;https&quot;</span>).<span class="ruby-identifier">zero?</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-request" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">request</span><span
                                class="method-args">(uri, request_class, last_modified = nil) { |req| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Performs a Net::HTTP request of type <code>request_class</code> on <code>uri</code> returning a Net::HTTP response object.  request maintains a table of persistent connections to reduce connect overhead.</p>

                              <div class="method-source-code" id="request-source">
            <pre><span class="ruby-comment"># File rubygems/remote_fetcher.rb, line 312</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">request</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">request_class</span>, <span class="ruby-identifier">last_modified</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">proxy</span> = <span class="ruby-identifier">proxy_for</span> <span class="ruby-ivar">@proxy</span>, <span class="ruby-identifier">uri</span>
  <span class="ruby-identifier">pool</span>  = <span class="ruby-identifier">pools_for</span>(<span class="ruby-identifier">proxy</span>).<span class="ruby-identifier">pool_for</span> <span class="ruby-identifier">uri</span>

  <span class="ruby-identifier">request</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">request_class</span>, <span class="ruby-identifier">last_modified</span>, <span class="ruby-identifier">pool</span>

  <span class="ruby-identifier">request</span>.<span class="ruby-identifier">fetch</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">req</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">yield</span> <span class="ruby-identifier">req</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-s3_uri_signer" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">s3_uri_signer</span><span
                                class="method-args">(uri)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>we have our own signing code here to avoid a dependency on the aws-sdk gem</p>

                              <div class="method-source-code" id="s3_uri_signer-source">
            <pre><span class="ruby-comment"># File rubygems/remote_fetcher.rb, line 279</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">s3_uri_signer</span>(<span class="ruby-identifier">uri</span>)
  <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">S3URISigner</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">uri</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Instance Methods</h3>
                </header>

                  <div id="method-i-pools_for" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">pools_for</span><span
                                class="method-args">(proxy)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="pools_for-source">
            <pre><span class="ruby-comment"># File rubygems/remote_fetcher.rb, line 337</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">pools_for</span>(<span class="ruby-identifier">proxy</span>)
  <span class="ruby-ivar">@pool_lock</span>.<span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-ivar">@pools</span>[<span class="ruby-identifier">proxy</span>] <span class="ruby-operator">||=</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span><span class="ruby-operator">::</span><span class="ruby-constant">ConnectionPools</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">proxy</span>, <span class="ruby-ivar">@cert_files</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-proxy_for" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">proxy_for</span><span
                                class="method-args">(proxy, uri)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="proxy_for-source">
            <pre><span class="ruby-comment"># File rubygems/remote_fetcher.rb, line 333</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">proxy_for</span>(<span class="ruby-identifier">proxy</span>, <span class="ruby-identifier">uri</span>)
  <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">proxy_uri</span>(<span class="ruby-identifier">proxy</span> <span class="ruby-operator">||</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">get_proxy_from_env</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span>))
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is a service of <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>, purveyors of fine <a href='https://jamesbritt.bandcamp.com/'>dance noise</a></p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

